package com.maimao.model.kill;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.*;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 秒杀商品
 */
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder
@TableName("mm_kill_goods")
public class KillGoods implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(type = IdType.AUTO)
    /**
     * 秒杀id
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long id;

    /**
     * 商品id
     */
    @TableField("goods_id")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long goodsId;

    /**
     * skuId
     */
    @TableField("sku_id")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long skuId;

    @TableField("shop_id")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long shopId;

    /**
     * 图片
     */
    @TableField("pic")
    private String pic;

    /**
     * 规格展示值
     */
    @TableField("spec_str")
    private String specStr;

    /**
     * sku参数
     */
    @TableField("sku_param")
    private String skuParam;

    /**
     * 商品名
     */
    @TableField("sku_name")
    private String skuName;

    /**
     * sku选项index
     */
    @TableField("spec_indexes")
    private String specIndexes;

    /**
     * 秒杀剩余库存
     */
    @TableField("stock")
    private Integer stock;

    /**
     * 原价
     */
    @TableField("raw_price")
    private BigDecimal rawPrice;

    /**
     * 秒杀价
     */
    @TableField("kill_price")
    private BigDecimal killPrice;

    /**
     * 折扣
     */
    @TableField("discount")
    private Integer discount;

    /**
     * 活动id
     */
    @TableField("activity_id")
    private Integer activityId;

    /**
     * 排期id
     */
    @TableField("schedule_id")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long scheduleId;

    /**
     * 开始时间
     */
    @TableField("start_time")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime startTime;

    /**
     * 结束时间
     */
    @TableField("`end_time`")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime endTime;

    /**
     * 1 有效 0 无效
     */
    @TableField("`status`")
    private Integer status;

    @TableField("give_integral")
    private Boolean giveIntegral;

    @Override
    public String toString() {
        return "KillGoods{" +
                "id=" + id +
                ", goodsId=" + goodsId +
                ", skuId=" + skuId +
                ", shopId=" + shopId +
                ", pic='" + pic + '\'' +
                ", specStr='" + specStr + '\'' +
                ", skuParam='" + skuParam + '\'' +
                ", skuName='" + skuName + '\'' +
                ", specIndexes='" + specIndexes + '\'' +
                ", stock=" + stock +
                ", rawPrice=" + rawPrice +
                ", killPrice=" + killPrice +
                ", discount=" + discount +
                ", activityId=" + activityId +
                ", scheduleId=" + scheduleId +
                ", startTime=" + startTime +
                ", endTime=" + endTime +
                ", status=" + status +
                ", giveIntegral=" + giveIntegral +
                '}';
    }
}